/* eslint-disable @typescript-eslint/no-empty-object-type */
import core = require("@babel/core");
import generator = require("@babel/generator");
import parser = require("@babel/parser");
import traverse = require("@babel/traverse");
import t = require("@babel/types");

interface PluginOption {}
function plugin({ types }: { types: typeof t }): traverse.Node {
  return {
    visitor: {
      Identifier(path) {
        // reverse the name: JavaScript -> tpircSavaJ
        path.node.name = `prefix_${path.node.name}`
          // eslint-disable-next-line unicorn/prefer-spread
          .split("")
          .reverse()
          .join("");
      },
    },

    // visitor: {
    //   // 这里可以定义各种节点的访问器
    //   // Identifier(path: any): t.Node {
    //   //   // 示例：将所有标识符名称添加前缀
    //   //   const newName = `prefix_${path.node.name}`;
    //   //   path.node.name = newName;
    //   //   return path;
    //   // },
    // },
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
  } as core.PluginObj<PluginOption> as any;
}

export { plugin, plugin as default };
